﻿package plugin.bossChallenge.ui
{
    import com.core.*;
    import manager.*;
    import morn.core.handlers.*;
    import plugin.bossChallenge.*;
    import plugin.taskdialog.consts.*;
    import uiresource.boss.*;

    public class YeWaiItemCtrl extends YeWaiBossListUI
    {
        private var cfgMapList:Array;
        private var ui:BossChallengeUICtrl;
        private var _data:Object;
        public var isChuan:int = 0;

        public function YeWaiItemCtrl()
        {
            this.cfgMapList = ConfigDictionary.data.maplist;
            return;
        }// end function

        override protected function initialize() : void
        {
            super.initialize();
            enterBtn.clickHandler = new Handler(this.clickHandler);
            return;
        }// end function

        public function get data() : Object
        {
            return this._data;
        }// end function

        public function set data(param1:Object) : void
        {
            this._data = param1;
            if (this.isChuan == 0)
            {
                enterBtn.visible = true;
                label.visible = false;
                enterBtn.label = param1.mapname + "[传]";
            }
            else
            {
                enterBtn.visible = false;
                label.visible = true;
                label.text = param1.mapname;
            }
            return;
        }// end function

        private function clickHandler() : void
        {
            var _loc_3:Object = null;
            var _loc_4:Array = null;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_1:* = UserData.getUserData("level");
            var _loc_2:* = UserData.getUserData("rein");
            if ((this.data.map as String).search("#") == -1)
            {
                _loc_3 = ConfigDictionary.data.sysnpc[this.data.map];
                if (_loc_3)
                {
                    PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.Fly, {x:_loc_3.x, y:_loc_3.y, tostageid:_loc_3.stageid});
                    ModelProxy.change("data", "taskfindpath", _loc_3.npcid);
                }
                else
                {
                    ModelProxy.change("movetips", "error", "暂时还没有此NPC");
                    return;
                }
            }
            else
            {
                _loc_4 = (this.data.map as String).split("#");
                _loc_5 = this.data.level;
                _loc_6 = UserData.getUserData("mapid");
                if (_loc_4[0] == _loc_6)
                {
                    ModelProxy.change("movetips", "error", "您已经传送到该位置");
                    return;
                }
                if (_loc_5 < 1000)
                {
                    if (_loc_1 < _loc_5)
                    {
                        WarningManager.show(32, [_loc_5]);
                        return;
                    }
                }
                else
                {
                    _loc_7 = _loc_5 / 1000;
                    if (_loc_2 < _loc_7)
                    {
                        WarningManager.show(33, [_loc_7]);
                        return;
                    }
                }
                ModelProxy.change("plugin", "sendSysMsg", {name:"taskdialog", param:{x:_loc_4[1], y:_loc_4[2], tostageid:_loc_4[0]}, cmd:112});
            }
            ModelProxy.change("bossChallenge", "close", null);
            return;
        }// end function

    }
}
